/*
 * ThreeByteRing.h
 *
 *  Created on: 29-Jun-2009
 *      Author: nrqm
 */

#ifndef THREEBYTERING_H_
#define THREEBYTERING_H_

#include <avr/io.h>

class ThreeByteRing
{
private:
	uint8_t ring[3];
	uint8_t size;
	int8_t head_index;
	int8_t tail_index;
public:
	ThreeByteRing();

	/**
	 * Add an integer to the ring buffer.  If the buffer is full, then the oldest byte is dropped from the
	 * buffer head.
	 */
	void Add(uint8_t value);

	/**
	 * Remove the byte from the buffer head.
	 */
	uint8_t Remove();

	/**
	 * Retrieve the byte at the buffer head without removing it.
	 */
	uint8_t Peek();

	/**
	 * Get the number of bytes in the buffer (0 to 3).
	 */
	uint8_t Size();
};

#endif /* THREEBYTERING_H_ */
